<?php
require_once("./include/membersite_config.php");
if($fgmembersite->CheckLogin())
{
    $_SESSION['user_id'] = $fgmembersite->UserID();
    echo 'Hello ', $fgmembersite->UserFullName();
}
/*if (logged_in()) {
  $user_data = user_data('name');
  echo 'Hello ', $user_data['name'];
  //print_r(user_data('name', 'email'));
}*/ else {

    

    if(isset($_POST['login']))
    {
      if($fgmembersite->Login())
      {
         $fgmembersite->RedirectToURL("index.php");
      }
    }
?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
      <meta http-equiv='Content-Type' content='text/html'; charset='utf-8'/>
      <title>Login</title>
      <link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css" />
      <script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
</head>

<body>
<div id='fg_membersite'>
<form id='login' action="<?php echo $fgmembersite->GetSelfScript(); ?>" method='post' accept-charset='UTF-8'>

<input type='hidden' name='login' id='login' value='1'/>





<!-- <form action="" method="post"> -->
	<div><span class='error'><?php echo $fgmembersite->GetErrorMessageLogin(); ?></span></div>
	   
	    <label for='username' >Email:</label>
	     <fieldset id=f1>
	     <span id='login_username_errorloc' class='error'></span>
	    <input type='text' id='rep' name='username' id='username' value="<?php echo $fgmembersite->SafeDisplay('username') ?>" maxlength="50" />
        </fieldset >
      
    
     <label for='password' >Password:</label> 
		  <fieldset id=f2>
		   <span id='login_password_errorloc' class='error'></span>
		 <input type='password' id='rep' name='password' id='password'  maxlength="50" />
        </fieldset >     
      <input type='submit' class="button" name='login' value='Log in' />
		          
	


</form>	
</div>
<script type='text/javascript'>
// <![CDATA[

    var frmvalidator  = new Validator("login");
    frmvalidator.EnableOnPageErrorDisplay();
    frmvalidator.EnableMsgsTogether();
    frmvalidator.addValidation("username","req","&nbsp&nbsp E-mail empty &nbsp&nbsp");
    frmvalidator.addValidation("password","req","&nbsp&nbsp password empty &nbsp&nbsp");

// ]]>
</script>
</body>
</html>

<!--
}

if (isset($_POST['login_email'], $_POST['login_password'])) {
  $login_email = $_POST['login_email'];
  $login_password = $_POST['login_password'];
  
  $errors = array();
  
  if (empty($login_email) || empty($login_password)) {
    $errors[] = 'Email and password required';
	
  }else {
  
  $login = login_check($login_email, $login_password);
  
  if ($login === false) {
	$errors[] = 'Unable to log you in, please check your e-mail or password';
  }
}

  if (!empty($errors)) {
	foreach ($errors as $error) {
	  echo $error, '<br />';
	}
   } else {
     $_SESSION['user_id'] = $login;
	 header('Location: index.php');
	 exit();
	}
	
	
}
-->

<?php } ?>

